import Vue from "vue";
import Router from "vue-router";
import login from "@/page/login";
import register from "@/page/register";
import index from "@/page/index";
import myComment from "@/page/myComment";
import bookinfo from "@/page/bookinfo";
import search from "@/page/search";
import searchResult from "@/page/searchResult";

Vue.use(Router);

export default new Router({
  routes: [
    {
      path: "/",
      name: "login",
      component: login
    },
    {
      path: "/index",
      name: "index",
      component: index
    },
    {
      path: "/register",
      name: "register",
      component: register
    },
    {
      path: "/myComment",
      name: "myComment",
      component: myComment
    },
    {
      path: "/bookinfo",
      name: "bookinfo",
      component: bookinfo
    },
    {
      path: "/search",
      name: "search",
      component: search
    },
    {
      path: "/searchResult",
      name: "searchResult",
      component: searchResult
    }
  ]
});
//解决Avoided redundant navigation to current location: "/register".错误
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
};
